// 抽象生产方法
abstract class ProduceStrategy {
  abstract Decision(caption: number): void
}

// 夏季生产算法
class ProduceStrategySummer extends ProduceStrategy {
  Decision(caption: number): void {
    let capitalForC = caption * 0.1
    let countForC = Math.floor(capitalForC / 5)
    let capitalForI = caption * 0.9
    let countForI = Math.floor(capitalForI / 3)
    console.log(`生产巧克力蛋糕数量为： ${countForC}, 生产冰淇淋蛋糕数量为： ${countForI}`)

  }
}

// 冬季生产算法
class ProduceStrategyWinter extends ProduceStrategy {
  Decision(caption: number): void {
    let capitalForC = caption * 0.8
    let countForC = Math.floor(capitalForC / 5)
    let capitalForI = caption * 0.2
    let countForI = Math.floor(capitalForI / 3)
    console.log(`生产巧克力蛋糕数量为： ${countForC}`)
    console.log(`生产冰淇淋蛋糕数量为： ${countForI}`)

  }
}

class ProduceContext {
  private ps: ProduceStrategy

  constructor(changeType: string) {
    switch (changeType) {
      case 'summer':
        this.ps = new ProduceStrategySummer()
        break
      case 'winter':
        this.ps = new ProduceStrategyWinter()
        break
      default:
        throw new TypeError('不存在该种策略')
    }
  }

  GetDesision(capital: number) {
    this.ps.Decision(capital)
  }
}

(function () {
  let produceContext: ProduceContext
  produceContext = new ProduceContext('winter')
  produceContext.GetDesision(101)
}())



